﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ITAP.ContourBuilder.Manipulation;
using ITAP.ContourBuilder.Operations;

namespace ITAP.ContourBuilder.GUI
{
    public class ExecutableControlManager
    {
        public static ToolStrip BuildExecutableToolstrip(ExecutableToolStrip toolStrip, ContourControl control)
        {
            ContourAction action;

            // Здесь заполняется ToolStrip.
            //-------------------------
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandEnterPolyline(control)));
            //-------------------------
            //action = new ActionSelectMove("Перемещение");
            //action.Control = control;
            //toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(action));
            //-------------------------
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandEnterText(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationCreateCurve()));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddCommentLine(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddElementDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddArcHeightDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddArcRadiusDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddElementLeaderDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddArcRadiusDimension2(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddComponentLeaderDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddHole(control)));
            //toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandNavigation(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddDiameterDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddRemoteRadiusDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddDirectDistanceDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandAddOffsetFromMainBorderDimension(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new CommandCreateCutout(control)));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationAlignConnectorsHorizontal()));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationAlignConnectorsVertical()));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationMoveConnectorsWithOffset()));
            toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationSetElementLength()));
            //toolStrip.Items.Add(ExecutableControlManager.CreateToolStripButton(new OperationOpenAnz()));
            control.Manipulator.CommandExecuted += new CommandExecutedDelegate(toolStrip.Manipulator_CommandExecuted);

            toolStrip.ItemClicked += toolStrip.ToolStripItemClicked;
            return toolStrip;
        }

        static void Manipulator_CommandExecuted(ICommand command)
        {
            throw new NotImplementedException();
        }

        private static ToolStripButton CreateToolStripButton(IExecutable executable)
        {
            ToolStripButton button = new ToolStripButton(executable.ToString(), executable.Icon);
            button.Tag = executable;
            return button;
        }
    }
}
